/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package usuario;

/**
 *
 * @author Deico
 */

import conexion.DB;
import java.util.Date;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.JOptionPane;

public class paciente {
    
    public static boolean isExist(String user){


        boolean flag = false;
        try {

          java.sql.Statement stat = DB.DB_CONNECTION.createStatement();
          ResultSet rs = stat.executeQuery("select rut from paciente where rut='"+user+"';");
          
          while (rs.next()) {
        
          flag=true;
          }
          rs.close();
          
          return flag;

         } catch (SQLException ex) { 
         JOptionPane.showMessageDialog(null, ex, "Error", JOptionPane.ERROR_MESSAGE);
         }
         return flag;
    }
    
    
    public static Object[] getpaciente(String user){
        
        Object[] paciente = new Object[12];
        try {

          java.sql.Statement stat = DB.DB_CONNECTION.createStatement();
          ResultSet rs = stat.executeQuery("select * from paciente where rut='"+user+"';");
          
          while (rs.next()) {
          
              paciente[0]= rs.getString("rut");
              paciente[1]= rs.getString("nombre");
              paciente[2]= rs.getString("apellidoP");
              paciente[3]= rs.getString("apellidoM");
              paciente[4]= rs.getDate("fechan");
              paciente[5]= rs.getString("direccion");
              paciente[6]= rs.getString("telefono");
              paciente[7]= rs.getString("email");
              paciente[8]= rs.getString("ocupacion");
              paciente[9]= rs.getString("escolaridad");
              paciente[10]= rs.getString("prevision");
              paciente[11]= rs.getString("estadoc");
     
              
          }
          rs.close();
          

         } catch (SQLException ex) { 
         JOptionPane.showMessageDialog(null, ex, "Error", JOptionPane.ERROR_MESSAGE);
         }
        return paciente;
    }
}
